/*  main thruster
th_main[0] = CreateThruster (_V(-.806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
th_main[1] = CreateThruster (_V( .806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
*/



#include "DeltaGlider.h"
#include "at1000.msh.resource.h"


double DeltaGlider::ReturnJetThrust(void)
{
	return MAX_JET_THRUST[0];
}
int DeltaGlider::getEngineMode(void)
{
	//1 is turbojet 0 is rocket 4= scram 5=hover
	return type;
}
void DeltaGlider::DeleteExhaust (void)
{
	if (!first_frame){
	SetThrusterLevel (th_main[0],0); //heres the problem, the first frame there is no th_main. So we must skip this
	SetThrusterLevel (th_main[1],0); //part if its the first frame. How? we make a bool yes/no
	}
	first_frame =0;
	bool delth;
	DelExhaustStream (main_exhaust1);
	DelExhaustStream (main_exhaust2);
	
	DelThrusterGroup (*th_main,THGROUP_MAIN,delth = false);
	DelThruster (*th_main);
	
}
/*
void DeltaGlider::revertEngine (int status)
{
#ifndef __contrails
#define __contrails
	double ispscale = (modelidx ? 0.8 : 1.0);
	PARTICLESTREAMSPEC contrail = {
		0, 1.0, 15, 200, 0.3, 6.5, 2, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC exhaust_main = {
		0, 2.0, 9, 150, 0.1, 0.5, 16, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	PARTICLESTREAMSPEC exhaust_hover = {
		0, 1.5, 20, 150, 0.1, 0.15, 9, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	PARTICLESTREAMSPEC exhaust_scram = {
		0, 2.0, 10, 150, 0.1, 0.2, 16, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
#endif
	DeleteExhaust();
		//status 2==turbojet, 3==rocket 4= scram 5=hover
	
	
	
//MAX_JET_THRUST[modelidx]
	if (status ==2)
	{  //turbo jet
		if (    !engine_go(0)   ){
			
			th_main[0] = CreateThruster (_V(-.806,-1.360456, -15.52272), _V(0,.0873082,.996181), 0, ph_jet,0, ISPJET*ispscale);
			th_main[1] = CreateThruster (_V( .806,-1.360456, -15.52272), _V(0,.0873082,.996181), 0, ph_jet,0, ISPJET*ispscale);
			thg_main = CreateThrusterGroup (th_main, 2, THGROUP_MAIN);
			main_temp = th_main;			
			type = 1;
				}//end of if (engine_go)

		else {
			//if (TURBINE_REVERSER == SYSTEM_ON) 
			//eng_settings=0;
			double Max_jet_thrustTEMP;
			if (GetAltitude() > 15240)
			{ Max_jet_thrustTEMP = setMaxThrust();}
			else
			{
				Max_jet_thrustTEMP = ReturnJetThrust();
			}
			if (TURBINE_REVERSER == SYSTEM_OFF)
			{
			th_main[0] = CreateThruster (_V(-.806,-1.360456, -15.52272), _V(0,.0873082,.996181), Max_jet_thrustTEMP, ph_jet, ISPJET, ISPJET*ispscale);
			th_main[1] = CreateThruster (_V( .806,-1.360456, -15.52272), _V(0,.0873082,.996181), Max_jet_thrustTEMP, ph_jet, ISPJET, ISPJET*ispscale);
			}
			if (TURBINE_REVERSER == SYSTEM_ON)
			{
			th_main[0] = CreateThruster (_V(-.806,-1.360456, -15.52272), _V(0,-.0873082,-.996181), Max_jet_thrustTEMP-77700, ph_jet, ISPJET, ISPJET*ispscale);
			th_main[1] = CreateThruster (_V( .806,-1.360456, -15.52272), _V(0,-.0873082,-.996181), Max_jet_thrustTEMP-77700, ph_jet, ISPJET, ISPJET*ispscale);
			}
					
			//main_exhaust1 = AddExhaustStream (th_main[0], _V(-1,-1.1,-5.4), &exhaust_scram);
			//main_exhaust2 = AddExhaustStream (th_main[1], _V( 1,-1.1,-5.4), &exhaust_scram);
			thg_main = CreateThrusterGroup (th_main, 2, THGROUP_MAIN);
			main_temp = th_main;
			type = 1;
		}//end of else
	}//end of if (status ==2)
	else if (status ==3)
	{
			// main thrusters
		winding_down=0;
		warmed_up = 0;
		th_main[0] = CreateThruster (_V(-.806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
		th_main[1] = CreateThruster (_V( .806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
		thg_main = CreateThrusterGroup (th_main, 2, THGROUP_MAIN);
		AddExhaust (th_main[0], 9, 1);
		AddExhaust (th_main[1], 9, 1);
		
		AddExhaustStream (th_main[0], _V(-.806, -1.388219, -15.21491), &contrail); //-.7843448 -1.360456 -15.46478
		AddExhaustStream (th_main[1], _V( .806, -1.388219, -15.21491), &contrail);
		
		AddExhaustStream (th_main[0], _V(-.806, -1.388219, -15.21491), &exhaust_main);
		AddExhaustStream (th_main[1], _V(.806, -1.388219, -15.21491), &exhaust_main);
		type = 0;
	}
	else if (status == 4)
	{
		winding_down=0;
		warmed_up = 0;
		type = 4;
		setScram();
		ScramjetThrust();
		static int ctrl = 0;
		SetScramLevel(ctrl, 1);
	}
	/*else if (status == 5) currently doesnt work, working on now
	{
		//hover engines
		winding_down=0;
		warmed_up = 0;
		th_hover[0] = CreateThruster (_V(-.806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
		th_hover[1] = CreateThruster (_V( .806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
		
		thg_main = CreateThrusterGroup (th_hover, 2, THGROUP_MAIN);
		AddExhaust (th_hover[0], 9, 1);
		AddExhaust (th_hover[1], 9, 1);
		
		th_main[0] = CreateThruster (_V(-.806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
		th_main[1] = CreateThruster (_V( .806,-1.360456, -15.52272), _V(0,.0873082,.996181), MAX_MAIN_THRUST[modelidx], ph_main, ISP, ISP*ispscale);
		
		AddExhaustStream (th_hover[0], _V(-.806, -1.388219, -15.21491), &contrail); //-.7843448 -1.360456 -15.46478
		AddExhaustStream (th_main[1], _V( .806, -1.388219, -15.21491), &contrail);
		
		AddExhaustStream (th_main[0], _V(-.806, -1.388219, -15.21491), &exhaust_main);
		AddExhaustStream (th_main[1], _V(.806, -1.388219, -15.21491), &exhaust_main);
		type = 5; //currently doesnt work, working on now
	}*/
//}
bool DeltaGlider::engine_go(bool x)
{
	if (x==0)
		return Jetengine_on;
	else
		return Jetengine_on1;
}
bool DeltaGlider::engine_go(DoorStatus *x, bool which)
{
	//{ DOOR_CLOSED, DOOR_OPEN, DOOR_CLOSING, DOOR_OPENING }
	if (!warmed_up)
		*x = DOOR_OPENING;
	else
		*x = DOOR_OPEN;
	if (eng_settings == 0)
		*x = DOOR_CLOSED;
	else if (engine_turn_off ==1)
		*x = DOOR_CLOSING;

	return Jetengine_on;
}
bool DeltaGlider::APU_go(void)
{
	return APU_on;
}

void DeltaGlider::engine_goSET(bool x, bool which)
{
	if (which)
		Jetengine_on1 = x;
	else
		Jetengine_on = x;
}
void DeltaGlider::APU_goSET(bool x)
{
	APU_on = x;
}


bool DeltaGlider::engine_activateJET(bool x, bool which)
{
	//x=0 is off, 1 is on
	if (which){
			engine_goSET(x, which);
			if (x==0){
				eng_settings=0;
				winding_down=0;
				warmed_up = 0;
				Jetengine_on = 0;
				engine_turn_off = 0;
				//revertEngine(2);
			}
			else{
				engine_turn_off = 1;
				winding_down = 1;
				Jetengine_on = 1;
				//revertEngine(2);
			}
			return !engine_turn_off;
	}
	else
	{
			engine_goSET(x, which);
				if (x==0){
					eng_settings1=0;
					winding_down1=0;
					warmed_up1 = 0;
					Jetengine_on1 = 0;
					engine_turn_off1 = 0;
					//revertEngine(2);
					
				}
				else{
					engine_turn_off1 = 1;
					winding_down1 = 1;
					Jetengine_on1 = 1;
					//revertEngine(2);
				}
				return !engine_turn_off;
	}


}



void DeltaGlider::setScram (void)
{
	PARTICLESTREAMSPEC exhaust_scram = {
		0, 2.0, 10, 150, 0.1, 0.2, 16, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	// **************** scramjet definitions ********************
			//if (scramjet) {
				VECTOR3 dir = {0.0, sin(SCRAM_DEFAULT_DIR), cos(SCRAM_DEFAULT_DIR)};

				for (int i = 0; i < 2; i++) {
					th_main[i] = CreateThruster (_V(i?0.9:-0.9, -0.8, -5.6), dir, 0, ph_scram, 0);
					scramjet->AddThrusterDefinition (th_main[i], SCRAM_FHV[modelidx],
						SCRAM_INTAKE_AREA, SCRAM_TEMAX[modelidx], SCRAM_MAX_DMF[modelidx]);
				//}

				// thrust rating and ISP for scramjet engines are updated continuously
				//AddExhaust (th_main[0], 10.0, 0.5);
				//AddExhaust (th_main[1], 10.0, 0.5);
				PSTREAM_HANDLE ph;
				ph = AddExhaustStream (th_main[0], _V(-1,-1.1,-5.4), &exhaust_scram);
				if (ph) oapiParticleSetLevelRef (ph, scram_intensity+0);
				ph = AddExhaustStream (th_main[1], _V( 1,-1.1,-5.4), &exhaust_scram);
				if (ph) oapiParticleSetLevelRef (ph, scram_intensity+1);
			}
			thg_main = CreateThrusterGroup (th_main, 2, THGROUP_MAIN);
}
double DeltaGlider::setMaxThrust(void)
{
	return (ReturnJetThrust() - ((GetAltitude() - 15240) * 53));
}


//SetThrusterIsp,
void DeltaGlider::jet(int status)
{
	if (status)
	SetThrusterIsp(main_temp,6316,3000,101.4e3);
}
void DeltaGlider::handleJet(bool x)
{
	
	if (x==0 && engine_go(0)){
			if (!warmed_up)
			{
				if (eng_settings < .75){
					eng_settings += .01;}
				else {warmed_up = 1; winding_down =1;}

				SetThrusterLevel(th_main[0], eng_settings);
				//SetThrusterLevel(th_main[1], eng_settings);
			}
			if (winding_down)
			{
				eng_settings -= .01;
				if (eng_settings < .10)
				 {winding_down = 0; }
				if (engine_turn_off && eng_settings > 0){
					winding_down = 1;
					if (eng_settings < 0.01 && eng_settings > -0.01){
						eng_settings = 0.01;
						engine_turn_off = 0;
						engine_goSET(0, 0);
					}
				}
				
				SetThrusterLevel(th_main[0], eng_settings);
				//SetThrusterLevel(th_main[1], eng_settings);
			}
			if ((GetThrusterLevel(th_main[0]) < .11) ){
			SetThrusterLevel(th_main[0], 0.1);//makes so that the jet is always on, as jets cannot turn off/on like rockets can
			//SetThrusterLevel(th_main[1], 0.1);
			}
			
	}//end of if 1
	
	else if (x==1 && engine_go(1))
	{
			if (!warmed_up1)
			{
				if (eng_settings1 < .75){
					eng_settings1 += .01;}
				else {warmed_up1 = 1; winding_down1 =1;}

				//SetThrusterLevel(th_main[0], eng_settings);
				SetThrusterLevel(th_main[1], eng_settings1);
			}
			if (winding_down1)
			{
				eng_settings1 -= .01;
				if (eng_settings1 < .10)
				 {winding_down1 = 0; }
				if (engine_turn_off1 && eng_settings1 > 0){
					winding_down1 = 1;
					if (eng_settings1 < 0.01 && eng_settings1 > -0.01){
						eng_settings1 = 0.01;
						engine_turn_off1 = 0;
						engine_goSET(0, 1);
					}
				}
				
				//SetThrusterLevel(th_main[0], eng_settings);
				SetThrusterLevel(th_main[1], eng_settings1);
			}
			if ((GetThrusterLevel(th_main[1]) < .11) ){
			//SetThrusterLevel(th_main[0], 0.1);//makes so that the jet is always on, as jets cannot turn off/on like rockets can
			SetThrusterLevel(th_main[1], 0.1);}
			}//end of engine go
			
}//end of handle jet

	

void DeltaGlider::RCS_MODE ()//right mouse button
{
   	
	//RCS normal mode
    /*
	DelThrusterGroup(THGROUP_ATT_PITCHUP);
	DelThrusterGroup(THGROUP_ATT_PITCHDOWN);
	DelThrusterGroup(THGROUP_ATT_YAWLEFT);
	DelThrusterGroup(THGROUP_ATT_YAWRIGHT);
	DelThrusterGroup(THGROUP_ATT_BANKLEFT);
	DelThrusterGroup(THGROUP_ATT_BANKRIGHT);
	DelThrusterGroup(THGROUP_ATT_RIGHT);
	DelThrusterGroup(THGROUP_ATT_LEFT);
	DelThrusterGroup(THGROUP_ATT_UP);
	DelThrusterGroup(THGROUP_ATT_DOWN);
	DelThrusterGroup(THGROUP_ATT_FORWARD);
	DelThrusterGroup(THGROUP_ATT_BACK);
	//DelThrusters	
	DelThruster (th_att_rot_up[2] ) ,2;
	DelThruster (th_att_rot_down[2] ) ,2;
	DelThruster (th_att_lin_up[2] ) ,2;
	DelThruster (th_att_lin_down[2] ) ,2;
	DelThruster (th_att_rot_yaw_left[2]) ,2;
	DelThruster (th_att_rot_yaw_right[2] ) ,2;
	DelThruster (th_att_lin_left[2] ) ,2;
	DelThruster (th_att_lin_right[2]) ,2;
	DelThruster (th_att_rot_bank_left[2]) ,2;
	DelThruster (th_att_rot_bank_right[2]) ,2;
	DelThruster (th_att_lin_forward[1] ) ,1;
	DelThruster (th_att_lin_backward[1]) ,1;
	*/

	//(rotation  x  nose up/down)
	//ATT_PITCHUP
	th_att_rot_up[0] = CreateThruster (_V(0,0, 13.5), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP);//push up nose
	th_att_rot_up[1] = CreateThruster (_V(0,0,-13.5), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP);// push down tail
	//ATT_PITCHDOWN
	th_att_rot_down[0] = CreateThruster (_V(0,0, 13.5), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP);// down nose
	th_att_rot_down[1] = CreateThruster (_V(0,0,-13.5), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP);// up tail
    // (lenier y up/down ) 
	
	//ATT_UP
	th_att_lin_up[0] = CreateThruster (_V(0,0, 13.5), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP);//up front
	th_att_lin_up[1] = CreateThruster (_V(0,0,-13.5), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP);// up back
	//ATT_DOWN
	th_att_lin_down[0] = CreateThruster (_V(0,0, 13.5), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP);// down front
	th_att_lin_down[1] = CreateThruster (_V(0,0,-13.5), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP);// down back
	
	//ATT_PITCHUP Exhaust
	AddExhaust (th_att_rot_up[0],2.5,.08,_V(1.389552, -1.514521, 13.2519), _V(0, -1,0));
    AddExhaust (th_att_rot_up[1],2.5,.08,_V(-1.389552, -1.514521, 13.2519), _V(0, -1,0));
    AddExhaust (th_att_rot_up[0],2.5,.08,_V(1.5686, -0.93105, -13.829657), _V(0, 1,0));
    AddExhaust (th_att_rot_up[1],2.5,.08,_V(-1.5686, -0.93105 ,-13.829657), _V(0, 1,0));

   //ATT_PITCHDOWN Exhaust
	AddExhaust (th_att_rot_down[0],2.5,.08,_V(0.551671, 0.0501864, 13.398066), _V(0, 1,0));
    AddExhaust (th_att_rot_down[1],2.5,.08,_V(-0.544715, 0.0507204, 13.398064), _V(0, 1,0));
    AddExhaust (th_att_rot_down[0],2.5,.08,_V(1.725562, -2.115695, -13.791195), _V(0, -1,0));
    AddExhaust (th_att_rot_down[1],2.5,.08,_V(-1.725562, -2.115766, -13.791198), _V(0, -1,0));


	//ATT_UP Exhaust
	AddExhaust (th_att_lin_up[0],2.5,.08,_V(1.389552, -1.514521, 13.2519), _V(0, -1,0));
	AddExhaust (th_att_lin_up[1],2.5,.08,_V(-1.389552, -1.514521, 13.2519), _V(0, -1,0));
	AddExhaust (th_att_lin_up[0],2.5,.08,_V(1.725562, -2.115695, -13.791195), _V(0, -1,0));
    AddExhaust (th_att_lin_up[1],2.5,.08,_V(-1.725562, -2.115766, -13.791198), _V(0, -1,0));

	//ATT_DOWN Exhaust
	AddExhaust (th_att_lin_down[0],2.5,.08,_V(1.5686, -0.93105, -13.829657), _V(0, 1,0));
    AddExhaust (th_att_lin_down[1],2.5,.08,_V(-1.5686, -0.93105 ,-13.829657), _V(0, 1,0));
	AddExhaust (th_att_lin_down[0],2.5,.08,_V(0.551671, 0.0501864, 13.398066), _V(0, 1,0));
    AddExhaust (th_att_lin_down[1],2.5,.08,_V(-0.544715, 0.0507204, 13.398064), _V(0, 1,0));
	
	
		
	//ATT_PITCHUP
	CreateThrusterGroup (th_att_rot_up,   2, THGROUP_ATT_PITCHUP);
	//ATT_PITCHDOWN
	CreateThrusterGroup (th_att_rot_down, 2, THGROUP_ATT_PITCHDOWN);
	//ATT_UP
	CreateThrusterGroup (th_att_lin_up,   2, THGROUP_ATT_UP);
	//ATT_DOWN
	CreateThrusterGroup (th_att_lin_down, 2, THGROUP_ATT_DOWN);
	

	//(rotation x left) 
    //nose
	th_att_rot_yaw_left[0] = CreateThruster (_V(0, 0, 13.5), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);//  rotate nose left
	th_att_rot_yaw_left[1] = CreateThruster (_V(0, 0, 13.5), _V( -1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);//  rotate nose left
	// tail
	th_att_rot_yaw_left[2] = CreateThruster (_V(0, 0, -13.5), _V(1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);//  rotate tail left
	th_att_rot_yaw_left[3] = CreateThruster (_V(0, 0 ,-13.5), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);//  rotate tail left
	//(rotation x right)
    // nose
	th_att_rot_yaw_right[0] =  CreateThruster (_V(0, 0, 13.5), _V(1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); // rotate nose right
    th_att_rot_yaw_right[1] =  CreateThruster (_V(0, 0, 13.5), _V(1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); // rotate nose right
    // tail
    th_att_rot_yaw_right[2] =  CreateThruster (_V(0, 0, -13.5), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); //rotate tail right
    th_att_rot_yaw_right[3] =  CreateThruster (_V(0, 0, -13.5), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); //rotate tail right
	// nose left
	AddExhaust (th_att_rot_yaw_left[0],2.5,.08,_V(0.502112, 0.00967478, 13.595427), _V(1,0,0)); //good
	AddExhaust (th_att_rot_yaw_left[1],2.5,.08,_V(1.314854, -1.508831, 13.412804), _V(1,0,0));  //good
	//tail left
	AddExhaust (th_att_rot_yaw_left[2],2.5,.08,_V(-1.524808, -0.969017, -14.098297), _V(-1,0,0));
	AddExhaust (th_att_rot_yaw_left[3],2.5,.08,_V(-1.560847, -2.082096, -14.104946), _V(-1,0,0)); 
	// nose right
	AddExhaust (th_att_rot_yaw_right[0],2.5,.08,_V(-0.502112, 0.00967478, 13.595427), _V(-1,0,0)); //good
	AddExhaust (th_att_rot_yaw_right[1],2.5,.08,_V(-1.314854, -1.508831, 13.412804), _V(-1,0,0));  //good
	// tail right
	AddExhaust (th_att_rot_yaw_right[2],2.5,.08,_V(1.524808, -0.969017, -14.098297), _V(1,0,0));
	AddExhaust (th_att_rot_yaw_right[3],2.5,.08,_V(1.560847, -2.082096, -14.104946), _V(1,0,0));
	//(lenier y left/right)
    //ATT_LEFT
    th_att_lin_left[0] = CreateThruster (_V(0,0, 13.5), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);// push front left
    th_att_lin_left[1] = CreateThruster (_V(0,0,-13.5), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); //push back left
    th_att_lin_left[2] = CreateThruster (_V(0,0, 13.5), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);// push front left
    th_att_lin_left[3] = CreateThruster (_V(0,0,-13.5), _V(-1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); //push back left
	//ATT_LEFT nose
	AddExhaust (th_att_lin_left[0],2.5,.08,_V(0.502112, 0.00967478, 13.595427), _V(1,0,0));
	AddExhaust (th_att_lin_left[1],2.5,.08,_V(1.314854, -1.508831, 13.412804), _V(1,0,0));
	//ATT_LEFT tail
	AddExhaust (th_att_lin_left[2],2.5,.08,_V(1.524808, -0.969017, -14.098297), _V(1,0,0));
	AddExhaust (th_att_lin_left[3],2.5,.08,_V(1.560847, -2.082096, -14.104946), _V(1,0,0));
	
	
	
	//ATT_RIGHT
	th_att_lin_right[0] = CreateThruster (_V(0,0, 13.5), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); //push front right
    th_att_lin_right[1] = CreateThruster (_V(0,0, 13.5), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);// push back right	
    th_att_lin_right[2] = CreateThruster (_V(0,0, -13.5), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP); //push front right
    th_att_lin_right[3] = CreateThruster (_V(0,0, -13.5), _V( 1,0,0), MAX_RCS_THRUST, ph_rcs, ISP);// push back right
	
	//ATT_LEFT nose
	AddExhaust (th_att_lin_right[0],2.5,.08,_V(-0.502112, 0.00967478, 13.595427), _V(-1,0,0));
	AddExhaust (th_att_lin_right[1],2.5,.08,_V(-1.314854, -1.508831, 13.412804), _V(-1,0,0));
	//ATT_LEFT tail
	AddExhaust (th_att_lin_right[2],2.5,.08,_V(-1.524808, -0.969017, -14.098297), _V(-1,0,0));
	AddExhaust (th_att_lin_right[3],2.5,.08,_V(-1.560847, -2.082096, -14.104946), _V(-1,0,0));
		
	CreateThrusterGroup (th_att_rot_yaw_left,   4, THGROUP_ATT_YAWLEFT);
	CreateThrusterGroup (th_att_rot_yaw_right, 4, THGROUP_ATT_YAWRIGHT);
	CreateThrusterGroup (th_att_lin_left,   4, THGROUP_ATT_LEFT);
	CreateThrusterGroup (th_att_lin_right, 4, THGROUP_ATT_RIGHT);
	

   //(roll wings right/left y )
	//ATT_BANKLEFT
	th_att_rot_bank_left[0] = CreateThruster (_V( 5.001125,0,0), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); //push left wing down
	th_att_rot_bank_left[1] = CreateThruster (_V(-5.001125,0,0), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); //push right wing up
	//ATT_BANKRIGHT
	th_att_rot_bank_right[0] = CreateThruster (_V(-5.001125,0,0), _V(0, 1,0), MAX_RCS_THRUST, ph_rcs, ISP); //push right wing down
	th_att_rot_bank_right[1] = CreateThruster (_V( 5.001125,0,0), _V(0,-1,0), MAX_RCS_THRUST, ph_rcs, ISP); //push left wing up
	
	
	AddExhaust (th_att_rot_bank_left[0],2.5,.08,_V(-5.001125, -1.264679, -0.00132503), _V(0,1,0));
	AddExhaust (th_att_rot_bank_left[1],2.5,.08,_V(4.988703, -1.897323, -0.0071635), _V(0,-1,0));
	
    AddExhaust (th_att_rot_bank_right[0],2.5,.08,_V(5.001125, -1.264679, -0.00132503), _V(0,1,0));
	AddExhaust (th_att_rot_bank_right[1],2.5,.08,_V(-4.988703, -1.897323, -0.0071635), _V(0,-1,0));
	
	CreateThrusterGroup (th_att_rot_bank_left, 2, THGROUP_ATT_BANKLEFT);
	CreateThrusterGroup (th_att_rot_bank_right, 2, THGROUP_ATT_BANKRIGHT);
	



	
	//( ship forward/backward z )
	th_att_lin_forward[0] = CreateThruster (_V(0,0,-14), _V(0,0, -1), MAX_RCS_THRUST, ph_rcs, ISP);//forward
	th_att_lin_forward[1] = CreateThruster (_V(0,0,-14), _V(0,0, -1), MAX_RCS_THRUST, ph_rcs, ISP);//forward
	th_att_lin_forward[2] = CreateThruster (_V(0,0,-14), _V(0,0, -1), MAX_RCS_THRUST, ph_rcs, ISP);//forward
	th_att_lin_forward[3] = CreateThruster (_V(0,0,-14), _V(0,0, -1), MAX_RCS_THRUST, ph_rcs, ISP);//forward
	
	
	
	th_att_lin_backward[0] = CreateThruster (_V(0,0, 14), _V(0,0,1), MAX_RCS_THRUST, ph_rcs, ISP);//backward
	th_att_lin_backward[1] = CreateThruster (_V(0,0, 14), _V(0,0,1), MAX_RCS_THRUST, ph_rcs, ISP);//backward
	th_att_lin_backward[2] = CreateThruster (_V(0,0, 14), _V(0,0,1), MAX_RCS_THRUST, ph_rcs, ISP);//backward
	th_att_lin_backward[3] = CreateThruster (_V(0,0, 14), _V(0,0,1), MAX_RCS_THRUST, ph_rcs, ISP);//backward
	
	
	//exhaust rendered at nose
	AddExhaust (th_att_lin_forward[0],2.5,.08,_V(0.548348, 0.178278, 13.120369), _V(0,0,1));
	AddExhaust (th_att_lin_forward[1],2.5,.08,_V(-0.548348, 0.178278, 13.120369), _V(0,0,1));
	
    AddExhaust (th_att_lin_forward[2],2.5,.08,_V(1.464717, -1.574383, 12.927718), _V(0,0,1));
	AddExhaust (th_att_lin_forward[3],2.5,.08,_V(-1.464717, -1.574383, 12.927718), _V(0,0,1));



	//exhaust rendered at tail
	AddExhaust (th_att_lin_backward[0],2.5,.08,_V(1.679934, -0.85612, -13.080674), _V(0,0,-1));
	AddExhaust (th_att_lin_backward[1],2.5,.08,_V(-1.679934, -0.85612, -13.080674), _V(0,0,-1));
	
	AddExhaust (th_att_lin_backward[2],2.5,.08,_V(2.002859, -2.214939, -13.005152), _V(0,0,-1));
	AddExhaust (th_att_lin_backward[3],2.5,.08,_V(-2.002859, -2.214939, -13.005152), _V(0,0,-1));
		
	CreateThrusterGroup (th_att_lin_forward,   4, THGROUP_ATT_FORWARD);
	CreateThrusterGroup (th_att_lin_backward, 4, THGROUP_ATT_BACK);
	
}
